package com.wxm.log.start.controller;

import com.wxm.log.api.annotation.Log;
import com.wxm.log.core.R;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author: wxm
 * @Date: 2021/10/5
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Log("GET-成功日志测试")
    @GetMapping(value = "get-ok/{pageNum}/{pageSize}")
    public R getOk(@PathVariable Integer pageNum,
                   @PathVariable Integer pageSize) {
        return R.ok("OK");
    }

    @Log("GET-失败日志测试")
    @GetMapping(value = "get-error/{pageNum}/{pageSize}")
    public R getError(@PathVariable Integer pageNum,
                        @PathVariable Integer pageSize) {
        throw new NullPointerException("空指针");
    }

    @Log("Post-成功日志测试")
    @PostMapping(value = "post-ok")
    public R postOk(@RequestBody List<String> list) {
        return R.ok(list);
    }

    @Log("Post-失败日志测试")
    @PostMapping(value = "post-error")
    public R postError(@RequestBody List<String> list) {
        return R.error("请求失败");
    }
}
